$(function(){

	$("#form-forget_password_reset").validate({
		rules: {
			password: {
				required: true,
				minlength: 6
			},
			confirm_password: {
				required: true,
				equalTo: "#password"
			}
		},
		messages: {
			password: {
				required: "请输入新密码",
				minlength: "密码最少输入6个字符"
			},
			confirm_password: {
				required: "请输入确认新密码",
				equalTo: "两次输入的密码不一致"
			}
		},
		
		submitHandler: function(form){
			
			var eSubmit = document.getElementById("submit");
			eSubmit.disabled = true;
		
			$("#forget_password_reset-msg").removeClass().html(g_sLoadingImage + "设置中...");
			
			$.ajax({
				type: "POST",
				url: "./?controller=user&task=ajax_forget_password_reset_save",
				data: $(form).serialize(),
				dataType: "json",
				success: function(json){
					
					eSubmit.disabled = false;
					
					if(json.status=="0")
					{
						$("#forget_password_reset-msg").removeClass().html("");
						$("#forget_password_reset-form").html( "<p>"+json.description+"</p>" );
					}
					else
					{
						$("#forget_password_reset-msg").attr("class", "message-error").html( json.description );
					}
				}
			});	

		}
	});
});

